package com.lifesaftypower.adapter;

import java.util.ArrayList;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;

import com.lifesaftypower.activity.R;
import com.lifesaftypower.product.ProductSeries;

public class ProductSeriesAdapter extends ArrayAdapter<ProductSeries> {
	private ArrayList<ProductSeries> _items;

	public ProductSeriesAdapter(Context context, int textViewResourceId,
			ArrayList<ProductSeries> items) {
		super(context, textViewResourceId, items);
		_items = items;
	}
	
	@Override
	public View getView(int position, View convertView, ViewGroup parent) { 
		View v = convertView;
		
		if (v == null) {
			LayoutInflater vi = (LayoutInflater) getContext().getSystemService(
					Context.LAYOUT_INFLATER_SERVICE);
			v = vi.inflate(R.layout.series_list_item, null);
		}
		
		ProductSeries series = _items.get(position);
		if (series != null) {
			TextView categoryName = (TextView) v
					.findViewById(R.id.tvSeriesName);

			if (categoryName != null) {
				categoryName.setText(series.get_name());
			}

		}
		
		return v;
	}
}
